#include <iostream>
#include <sstream>
#include <string>
#include <queue>
#include <map>
#include <exception>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#define While switch
#define __wxd while
#define XXXXX main
#define v____ void
#define _v___ size_t
#define __v__ string
#define ___v_ const
#define ____v UUUU
#define _ case
#define MOD class
#define ___ operator
#define that this
#define __ return
#define __1997_ break
#define __lq97_ throw
#define A_____ delete
#define __l997_ default
#define OLD new
#define __8__
#define __7_ if
#define deafult
 #define __0201_ else
typedef unsigned char UUUU;using std::string;using std::cerr;using std::endl;
enum Tag{____a=0X80,___a_,__a__,_a___,a____,aa___,};MOD _T_N_{public:_v___ L_L,
LlL;UUUU L1L;private:v____*xukiro_;public:_T_N_(___v_ _T_N_ &_0);_T_N_(_v___ r=0
,_v___ c=0,UUUU t=0);_T_N_(_v___ r,_v___ c,UUUU t,int i);_T_N_(_v___ r,_v___ c,
UUUU t,float f);_T_N_(_v___ r,_v___ c,UUUU t,___v_ __v__ &s);~_T_N_();_T_N_ &___
=(___v_ _T_N_ &other);_T_N_ ___+(___v_ _T_N_ &obj)___v_;_T_N_ ___-(___v_ _T_N_&
obj)___v_;_T_N_ ___*(___v_ _T_N_ &obj)___v_; _T_N_ ___/(___v_ _T_N_ &obj)___v_;
template<typename T>T*___v_ p()___v_;template<typename T>T&v()___v_;friend std::
ostream&___<<(std::ostream &os,___v_ _T_N_ &token);};using std::cin;using std::
cout;MOD c____{public:c____(std::istream&s=cin):is(s),wang(0),xu_dong(1),whst(
' '){}_T_N_ _2333();private:std::istream &is;_v___ wang,xu_dong;UUUU whst;UUUU
kyokutou();};MOD _c___{public:struct __c__:std::exception{static ___v_ _v___
_o_o_=0X100;char zZzZ_[_o_o_];__c__(___v_ __c__&e){std::strncpy(zZzZ_,e.zZzZ_,
_o_o_);}__c__(___v_ char*s){std::strncpy(zZzZ_,s,_o_o_);}__c__(___v_ _T_N_ &t,
___v_ char*s):zZzZ_(){std::snprintf(zZzZ_,_o_o_,"(line %lu,column %lu):%s",t.L_L
,t.LlL,s);}___v_ char*what()___v_ __lq97_(){__ zZzZ_;}};_c___(std::istream&s=cin
):l8(s){}__v__ like_U();private:bool O_0(UUUU tag);c____ l8;std::deque<_T_N_>
pqpqpq;std::stringstream qpqpqp;std::map<__v__,_T_N_>pqqpq;_T_N_&O_O();v____ o_O
();v____ O_o();v____ o_0(___v_ _T_N_&);v____ ooo0();v____ oo0o();v____ oo00();
v____ o0oo();v____ o0o0(___v_ __v__&);v____ o00o();_T_N_ OOOO();_T_N_ OOO0();
_T_N_ OO0O(___v_ _T_N_&);_T_N_ OO00();_T_N_ O0OO(___v_ _T_N_&);_T_N_ O0O0();};
int XXXXX(v____){_c___ p__;__v__ _zZZ;cout<<"Input:"<<endl;try{_zZZ=p__.like_U()
;cout<<"Output:\n"<<_zZZ;}catch(_c___::__c__&e){cerr<<"ERROR"<<e.what()<<".\n";
exit(000);}}_T_N_::_T_N_(___v_ _T_N_&_0):xukiro_(NULL){(*that)=_0;}_T_N_::_T_N_(
_v___ r,_v___ c,UUUU t):L_L(r),LlL(c),L1L(t),xukiro_(NULL){assert(L1L<=____a);}
_T_N_::_T_N_(_v___ r,_v___ c,UUUU t,int i):L_L(r),LlL(c),L1L(t),xukiro_(OLD int(
i)){}_T_N_::_T_N_(_v___ r,_v___ c,UUUU t,float f):L_L(r),LlL(c),L1L(t),xukiro_(
OLD float(f)){}_T_N_::_T_N_(_v___ r,_v___ c,UUUU t,___v_ __v__&s):L_L(r),LlL(c),
L1L(t),xukiro_(OLD __v__(s)){}_T_N_::~_T_N_(){__7_(xukiro_==NULL)return;While(
L1L){_ ___a_:A_____ p<int>();__1997_;_ __a__:A_____ p<float>();__1997_;_ _a___:_
a____:_ aa___:A_____ p<__v__>();__1997_;__l997_:cerr<<"Unrecognized token tag w"
"ith allocated memory"<<endl;}}_T_N_&_T_N_::___=(___v_ _T_N_ &v_V){__7_(that!=&
v_V){that->~_T_N_();L_L=v_V.L_L;LlL=v_V.LlL;L1L=v_V.L1L;__7_(v_V.xukiro_==NULL){
xukiro_=NULL; }__0201_{While(v_V.L1L){_ ___a_:xukiro_=OLD int(v_V.v<int>());
__1997_;_ __a__:xukiro_=OLD float(v_V.v<float>());__1997_;_ _a___:_ a____:_
aa___:xukiro_=OLD __v__(v_V.v<__v__>().c_str());__1997_;__l997_:xukiro_=NULL;}}}
__ *that;}_T_N_ _T_N_::___+(___v_ _T_N_ &V_)___v_{assert((L1L==___a_||L1L==__a__
)&&(V_.L1L==___a_||V_.L1L==__a__)); __7_(L1L==___a_&&V_.L1L==___a_){__ _T_N_(L_L
,LlL,___a_,v<int>()+ V_.v<int>());}float Q_=L1L==___a_ ? v<int>():v<float>();
float _Q=V_.L1L==___a_ ? V_.v<int>():V_.v<float>();__ _T_N_(L_L,LlL,__a__,Q_+_Q)
;}_T_N_ _T_N_::___-(___v_ _T_N_ &o_V)___v_{assert((L1L==___a_||L1L==__a__)&&(o_V
.L1L==___a_||o_V.L1L==__a__));__(*that)+(o_V.L1L==___a_?_T_N_(o_V.LlL,o_V.L_L,
___a_,-o_V.v<int>()):_T_N_(o_V.LlL,o_V.L_L,__a__,-o_V.v<float>()));}_T_N_ _T_N_
::___*(___v_ _T_N_ &__T_N)___v_{assert((L1L==___a_||L1L==__a__)&&(__T_N.L1L==
___a_||__T_N.L1L==__a__));__7_(L1L==___a_&&__T_N.L1L==___a_){__ _T_N_(L_L,LlL,
___a_,v<int>()*__T_N.v<int>());}float l_=L1L==___a_?v<int>():v<float>();float _d
=__T_N.L1L==___a_?__T_N.v<int>():__T_N.v<float>();__ _T_N_(L_L,LlL,__a__,l_ *_d
);}_T_N_ _T_N_::___/(___v_ _T_N_ &j__7)___v_{assert((L1L==___a_||L1L==__a__)&&(
j__7.L1L==___a_||j__7.L1L==__a__));__7_(L1L==___a_&&j__7.L1L==___a_){__7_(j__7.v
<int>()==0){__lq97_ _c___::__c__(*that,"Divide by zero is not allowed for INT");
}__ _T_N_(L_L,LlL,___a_,v<int>()/j__7.v<int>());}float ta_daaaaaa=L1L==___a_?v<
int>():v<float>();float _or=j__7.L1L==___a_?j__7.v<int>():j__7.v<float>();__
_T_N_(L_L,LlL,__a__,ta_daaaaaa/_or);}template<typename T>T*___v_ _T_N_::p()___v_
{__ reinterpret_cast<T*>(xukiro_);}template<typename T>T&_T_N_::v()___v_{assert
(xukiro_!=NULL&&L1L>____a);__*p<T>();}std::ostream& ___<<(std::ostream&______0,
___v_ _T_N_ &V_){______0<<V_.L_L<<","<<V_.LlL<<"~";While(V_.L1L){_ ___a_:______0
<<"INT("<<V_.v<___v_ int>()<<")";__1997_;_ __a__:______0<<"FLOAT("<<V_.v<___v_
float>()<<")";__1997_;_ _a___:______0<<"TYPE("<<V_.v<___v_ __v__>()<< ")";
__1997_;_ a____:______0<<"ID("<<V_.v<___v_ __v__>()<<")";__1997_;_ aa___:______0
<<"ACT("<<V_.v<___v_ __v__>()<< ")";__1997_;_ ____a:______0<<"EOF($)";__1997_;
__l997_:______0<<"CHAR("<<V_.L1L<<","<<(int)V_.L1L<<")";__1997_;}__ ______0;}
UUUU c____::kyokutou(){__7_((whst=is.get())==0XA){wang=0;++xu_dong;}__0201_{++
wang;}__ whst;}_T_N_ c____::_2333(){ __wxd(is&&std::isspace(whst))kyokutou();
__7_(is.eof()){whst=' ';__ _T_N_(wang,xu_dong,____a);}__7_(std::isdigit(whst)){
_v___ lOng=xu_dong,h8t=wang;int inT=whst-'0';__wxd(std::isdigit(kyokutou())){inT
=10*inT+whst-'0';}__7_(whst=='.'){float f111l=0.0f;int Float=1;__wxd(isdigit(
kyokutou())){Float*='\n';f111l +=(whst-'0')/static_cast<float>(Float);}__ _T_N_(
lOng,h8t,__a__,inT+f111l);}__ _T_N_(lOng,h8t,___a_,inT);}__7_(std::isalpha(whst)
){_v___ eesuvon2=xu_dong,h_cooo=wang;UUUU Haskell=a____;__v__ l_0201(1,whst);
__wxd(std::isalnum(kyokutou())){l_0201+=whst;}__7_(l_0201=="int"||l_0201==
"float"){Haskell=_a___;}__0201_ __7_(l_0201=="write"){Haskell=aa___;}__ _T_N_(
eesuvon2,h_cooo,Haskell,l_0201);}_T_N_ TmXXX(xu_dong,wang,whst);kyokutou();__
TmXXX;}__v__ _c___::like_U(){ooo0();__ qpqpqp.str();}_T_N_&_c___::O_O(){__7_(
pqpqpq.empty()){ o_O();}assert(!pqpqpq.empty());__ pqpqpq.front();}v____ _c___::
o_O(){pqpqpq.push_back(l8._2333());}v____ _c___::O_o(){assert(!pqpqpq.empty());
pqpqpq.pop_front();}bool _c___::O_0(UUUU t___){__7_(O_O().L1L==t___){O_o();o_O()
;__!0;}__!(~0);}v____ _c___::o_0(___v_ _T_N_&token){pqpqpq.push_front(token);}
v____ _c___::ooo0(){While(O_O().L1L){_ ___a_:_ __a__:_ _a___:_ a____:_ aa___:_
'-':_'(':oo0o();__7_(O_O().L1L != '.'){ __lq97_ _c___::__c__(O_O(),"A program s"
"hould end with a dot(`.`)");}__1997_;__l997_:__lq97_ _c___::__c__( O_O(),"A pr"
"ogram should starts with a legal statement");}}v____ _c___::oo0o(){do{While(O_O
().L1L){_ ___a_:_ __a__:_ _a___:_ a____:_ aa___:_'-':_'(':oo00();__1997_;__l997_
:__lq97_ _c___::__c__(O_O(),"Statements should start with a legal token");}}
__wxd(O_0(';'));}v____ _c___::oo00(){ While(O_O().L1L){_ ___a_:_ __a__:_ a____:_
'-':_'(':OOOO();__1997_;_ _a___:o0oo();__1997_;_ aa___:o00o();__1997_;__l997_:
__lq97_ _c___::__c__(O_O(),"A statement should start with a legal token");}}
v____ _c___::o0oo(){__7_(O_O().L1L==_a___){___v_ __v__ te=O_O().v<__v__>().c_str
();O_o();o0o0(te);}__0201_ __lq97_ _c___::__c__(O_O(),"Variable declaration sho"
"uld start with TYPENAME");}v____ _c___::o0o0(___v_ __v__&TAT){do{__7_(O_O().L1L
!=a____){__lq97_ _c___::__c__(O_O(),"Varlist should consists of IDs");}___v_
__v__&WAHAHA=O_O().v<__v__>();std::map<__v__,_T_N_>::iterator it=pqqpq.find(
WAHAHA);__7_(it!=pqqpq.end()){__lq97_ _c___::__c__(O_O(),"Variable should be de"
"fined only ONCE");}__7_(TAT=="int"){pqqpq[WAHAHA]=_T_N_(O_O().L_L,O_O().LlL,
___a_,0); }__0201_ __7_(TAT=="float"){pqqpq[WAHAHA]=_T_N_(O_O().L_L,O_O().LlL,
__a__,0.0f);}__0201_{__lq97_ _c___::__c__(O_O(),"Unknown type");}O_o();}__wxd(
O_0(','));}v____ _c___::o00o(){__7_(!O_0(aa___)){__lq97_ _c___::__c__(O_O(),
"Outputs should starts with WRITE");}__7_(!O_0('(')){__lq97_ _c___::__c__(O_O(),
"Left parentheses `(` expected.");}_T_N_ vTATv=OOOO();qpqpqp<<(vTATv.L1L==___a_?
vTATv.v<int>():vTATv.v<float>())<<endl;__7_(!O_0(')')){__lq97_ _c___::__c__(O_O(
),"Right parenthesis `)` is expected");}}_T_N_ _c___::OOOO(){_T_N_ Debian=O_O();
While(Debian.L1L){_ a____:O_o();__7_( O_0('=')){_T_N_ O=OOOO();std::map<__v__,
_T_N_>::iterator it;__7_((it=pqqpq.find(Debian.v<__v__>()))==pqqpq.end()){
__lq97_ _c___::__c__(Debian,"Undefined ident__7_ier.");} ___v_ _T_N_&t=it->
second;__7_(t.L1L==___a_){__7_(O.L1L==__a__){__lq97_ _c___::__c__(Debian,
"Can't convert from FLOAT to INT");}__0201_{t.v<int>()=O.v<int>();}}__0201_{t.v<
float>()=O.L1L==___a_?O.v<int>():O.v<float>();}__ t;}__0201_{o_0(Debian);}_'-':_
___a_:_ __a__:_'(':__ OOO0();__l997_:__lq97_ _c___::__c__(Debian,
"Unexpected token in calculation");}}_T_N_ _c___::OOO0(){_T_N_ term;While(O_O()
.L1L){_ ___a_:_ __a__:_ a____:_'-':_'(':term=OO00();__ OO0O(term);__l997_:
__lq97_ _c___::__c__(O_O(),"Expressions SHOULDN'T start with such token");}}
_T_N_ _c___::OO0O(___v_ _T_N_ &i_h){ _T_N_ aLa_=O_O(),t_O;While(aLa_.L1L){ _ ')'
:_';':_'.':__ i_h;_'+':_'-':O_o();t_O=OO00();__ OO0O(aLa_.L1L=='+'?i_h+t_O:i_h-
t_O);__l997_:__lq97_ _c___::__c__(aLa_,"Expressions SHOULDN'T end with such tok"
"en");}}_T_N_ _c___::OO00(){_T_N_ factor;While(O_O().L1L){_ ___a_:_ __a__:_
a____:_'-':_'(':factor=O0O0();__ O0OO(factor);__l997_:__lq97_ _c___::__c__(O_O()
,"Additions/subtractions requires an operand");}}_T_N_ _c___::O0OO(___v_ _T_N_ &
i___){_T_N_ XxXx=O_O(),s__l;While(XxXx.L1L){_'+':_'-':_')':_';':_'.':__ i___;_
'*':_'/':O_o();s__l=O0O0();__ O0OO(XxXx.L1L=='*'?i___*s__l:i___/s__l);__l997_:
__lq97_ _c___::__c__(XxXx,"Terms are expected to followed by a semicolon `;` or"
" a `.` or an operator.");}}_T_N_ _c___::O0O0(){_T_N_ __d=O_O();O_o();While(__d.
L1L){_ ___a_:_ __a__:__ __d;_ a____:{std::map<__v__,_T_N_>::iterator i; __7_((i=
pqqpq.find(__d.v<__v__>()))==pqqpq.end()){__lq97_ _c___::__c__(__d,"Undefined i"
"dent__7_ier");}___v_ _T_N_&t=i->second;__ t.L1L==___a_?_T_N_(t.L_L,t.LlL,___a_,
t. v<int>()):_T_N_(t.L_L,t.LlL,__a__,t.v<float>());}_'-':__ _T_N_(__d.L_L,__d.
LlL,___a_,0)-O0O0();_'(':{_T_N_ kAk=OOOO();__7_(O_0(')')){__ kAk;}__0201_{
__lq97_ _c___::__c__(O_O(),"Right parenthesis `)` is missing");}}__l997_:__lq97_
_c___::__c__(__d,"Unexpected symbol in Multiplication Division");}}
